<?php
/**
 * NIKE+ PHP API Implementation
 * The following example code shows how you can use this Nike+ API implementation.
 * See class file for further instructions on usage, modification and available data
 * 
 * @author Martin Sommervold (martin@sommervold.com) - 2011
 * @version 1.0
 */

require("classes/NikePlus.class.php");


# Create a new NikePlus object. The username and password is the same as you use to login to Nike+.
 
$Nike = new NikePlus('username(email)', 'password', false);

# Some basic summary information in the object

echo "Total flab burned, ever: $Nike->totalCalories kcal<br />
Total distance covered: $Nike->totalDistance km <br />
Total time spent running: $Nike->totalDuration <br />
";


# Go through all your runs and display some data about them. Have a look at classes/
 
echo 'Latest runs:<br /> ';
foreach($Nike->runs as $Run){
	echo "Run $Run->startTime:  $Run->distance km. <br />";
}

/*
 * Each run has curve details (speed, distance, on 10 second intervals, loaded into arrays)
 * This can be batch-loaded by giving a third parameter, true, to the NikePlus constructor.
 * Unfortunately, this will increase the load time for XML-data by N = the amount of runs you have,
 * and can be quite slow. Therefore the default is to NOT load curvedata, and rather provide that 
 * as an option for each Run-object. Issuing the command below will load curvedata into the object.
 * 
 * You can access that data through ->distanceIntervalData and ->speedIntervalData
 */

$Nike->runs[0]->loadRunDetails();

# Display curvedata
print_r($Nike->runs[0]->distanceIntervalData);